package com.dui;

import javax.swing.*;
import java.awt.*;
import java.util.Random;

public class Beetle {
    //定义图片
    int x;
    int y;
    int width;
    int height;
    int speed;
    //方向
    int dir = 1;
    //类型
    int type;
    //分值
    int count=1;
    static Image beetleImg;
    static Image[] beetleImgs = new Image[6];
    static {
        beetleImg = new ImageIcon("img/lang-0.jpg").getImage();
        for (int i = 0; i<beetleImgs.length;i++){
            beetleImgs[i] = new ImageIcon("img/lang-"+i+".png").getImage();
        }
    }
    public Beetle(){
        Random random = new Random();
        this.x =-this.beetleImg.getWidth(null);
        this.y = random.nextInt(800)+5;
        this.speed = 20;
    }
    int index=0;
    public void moveAndStep(){
        this.x +=this.speed;
        int i = index++/10%beetleImgs.length;
        this.beetleImg=this.beetleImgs[i];
    }

}
